package cn.ddz2;

import java.util.*;

public class PokerGame {
    //牌盒 Map
    //此时我们只要把牌跟序号产生对应关系就可以了，不需要按照序号进行排序，所以只要HashMap就可以了
    static List<Integer> list = new ArrayList<>();
    static Map<Integer,String> hm = new HashMap<>();

    static {
        String[] color = {"♦", "♣", "♥", "♠"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        //序号
        int serialNumber = 1;
        for (String n : number) {
            for (String c : color) {
                hm.put(serialNumber,c+n);
                list.add(serialNumber);
                serialNumber++;
            }
        }
        hm.put(serialNumber,"小王");
        list.add(serialNumber);
        serialNumber++;
        hm.put(serialNumber,"大王");
        list.add(serialNumber);
    }
    public PokerGame(){
        Collections.shuffle(list);
        Collections.shuffle(list);
        System.out.println(list);
        Set<Integer> lord = new TreeSet<>();
        Set<Integer> player1 = new TreeSet<>();
        Set<Integer> player2 = new TreeSet<>();
        Set<Integer> player3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            if (i<=2){
                lord.add(list.get(i));
                continue;
            }
            if (i%3==0){
                player1.add(list.get(i));
            }else if (i%3==1){
                player2.add(list.get(i));
            }else{
                player3.add(list.get(i));
            }
        }
        //看牌
        lookPoker("底牌",lord);
        lookPoker("钢脑壳",player1);
        lookPoker("大帅比",player2);
        lookPoker("蛋筒",player3);
    }

    /*
     * 参数一：玩家的名字
     * 参数二：牌的序号
     * */
    public void lookPoker(String name, Set<Integer> ts){
        System.out.println(name + ": ");
        for (Integer t : ts) {
            String s = hm.get(t);
            System.out.print(s + " ");
        }
        System.out.println();
    }
}
